package com.example.demo;

public class ForPJ {
    public static void main(String[] args) {
        String a="I am ST";
        System.out.println(new ForPJ().reverseWords(a));
    }

    public String reverseWords(String str){
        

        String[] newstrings=str.split(" ");
        StringBuffer stringBuffer=new StringBuffer("");
        for (int i = newstrings.length-1; i >-1 ; i--) {
            stringBuffer.append(newstrings[i]+" ");
        }
        String s = stringBuffer.toString();

        return s;

    }
}
